home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
DEMONSTR
/
ATEASY_2.ZIP
/
DLLEXAMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-29
|
5KB
|
144 lines
/****************************************************************************
PROGRAM: DLLEXAMP.c
PURPOSE: Demonstarte ATEasy DLL functions
using MSC 5.1+/QC-Win/Borland C++
VERSION: 1.10 (Dec-12-91)
FUNCTIONS:
- Max() : finds the max between 2 floats
- AverageArray() : find the avarage of float array
- NoSpaces() : delete leading & trailing spaces in a string
****************************************************************************/
#include "windows.h"
#include "ateasydl.h" /* contains ATEasy VAL, VAR parameters definitions */
#include "string.h" /* for memmove */
#include "ctype.h" /* for isspace */
/****************************************************************************
FUNCTION: LibMain(HANDLE, WORD, WORD, LPSTR)
PURPOSE: Is called by LibEntry. LibEntry is called by Windows when
the DLL is loaded. The LibEntry routine is provided in
the LIBENTRY.OBJ in the SDK Link Libraries disk. (The
source LIBENTRY.ASM is also provided.)
LibEntry initializes the DLL's heap, if a HEAPSIZE value is
specified in the DLL's DEF file. Then LibEntry calls
LibMain. The LibMain function below satisfies that call.
The LibMain function should perform additional initialization
tasks required by the DLL. In this example, no initialization
tasks are required. LibMain should return a value of 1 if
the initialization is successful.
****************************************************************************/
int FAR PASCAL LibMain(hModule, wDataSeg, cbHeapSize, lpszCmdLine)
HANDLE hModule;
WORD wDataSeg;
WORD cbHeapSize;
LPSTR lpszCmdLine;
{
return(1);
}
/****************************************************************************
FUNCTION: WEP(int)
PURPOSE: Performs cleanup tasks when the DLL is unloaded. WEP() is
called automatically by Windows when the DLL is unloaded (no
remaining tasks still have the DLL loaded). It is strongly
recommended that a DLL have a WEP() function, even if it does
nothing but returns success (1), as in this example.
****************************************************************************/
int FAR PASCAL WEP(bSystemExit)
int bSystemExit;
{
return(1);
}
/****************************************************************************
FUNCTION: Max(hWnd, dX1, dX2, lpdResult)
PURPOSE: Finds the max of 2 floats (dX1 & dX2) into lpdResult.
This function defined in ATEasy as:
Max(X1 : VAL FLOAT, X2 : VAL FLOAT, Result : VAR FLOAT) : SUB DLL
****************************************************************************/
VOID FAR PASCAL Max(hWnd, dX1, dX2, lpdResult)
HWND hWnd;
VAL_FLOAT dX1, dX2;
VAR_FLOAT lpdResult;
{
*lpdResult=dX1 > dX2 ? dX1 : dX2;
}
/****************************************************************************
FUNCTION: AverageArray(hWnd, FloatArray, lpdResult)
PURPOSE: Finds the avarage of FloatArray into lpdResult.
This function defined in ATEasy as:
AverageArray(Array : VAL FLOAT[], Result : VAR FLOAT) : SUB DLL
****************************************************************************/
VOID FAR PASCAL AverageArray(hWnd, FloatArray, lpdResult)
HWND hWnd;
VAL_AFLOAT FloatArray;
VAR_FLOAT lpdResult;
{
double ldResult=0.0;
short i;
for (i=0; i < FloatArray->nDim2; i++)
ldResult+=(FloatArray->Ptr.lpFloat)[i];
if (FloatArray->nDim2)
ldResult/=FloatArray->nDim2;
*lpdResult=ldResult;
}
/****************************************************************************
FUNCTION: NoSpaces(hWnd, String)
PURPOSE: Delete leading & trailing spaces in a string
This function defined in ATEasy as:
NoSpaces(Str : VAR String)
****************************************************************************/
VOID FAR PASCAL NoSpaces(hWnd, String)
HWND hWnd;
VAR_ASTRING String;
{
short i, j;
for (i=StrLen(String); i > 0; i--) /* delete trailing spaces */
if (!isspace(Str(String)[i-1])) break;
StrLen(String)=i;
for (j=0; j < i; j++) /* delete leading spaces */
if (!isspace(Str(String)[j])) break;
if (j) /* move to start */
{ StrLen(String)-=j;
memmove(Str(String), &Str(String)[j], StrLen(String));
}
}
/****************************************************************************
E - O - F
****************************************************************************/